var CommonApp = function(){
	return{
		/**
		 * 初始化登录条件
		 */
		init:function(){
			var openId = CommonApp.readStorage('openId');
			var shopId = CommonApp.readStorage('shopId');
			var accessToken = $("#accessToken").val();
			var tokenDate = $("#tokenDate").val();
			sessionStorage.setItem('webToken',accessToken);
			
			if(openId == null || openId == "" || openId == undefined){
				if(typeof window.sessionStorage == 'undefined'){ 	alert("请在微信客户端打开链接");return false;}
				sessionStorage.setItem('openId',$("#openId").val());
			}
			
			if(shopId == null || shopId == "" || shopId == undefined){
				if(typeof window.sessionStorage == 'undefined'){ 	alert("请在微信客户端打开链接");return false;}
				window.sessionStorage.setItem('shopId',$("#shopId").val());
			}
		},
		/**
		 * 校验是否微信内打开
		 */
		validate:function(){
			var ua = navigator.userAgent.toLowerCase();  
		    if(ua.match(/MicroMessenger/i)=="micromessenger") {  
		        return true;  
		    } else {  
		        return false;  
		    }  
		},
		/**
		 * 读取sessionStorage
		 */
		writeStorage:function(key,val){
			if(typeof window.sessionStorage == 'undefined'){ 	alert("请在微信客户端打开链接");return false;}
			sessionStorage.setItem(key,val);
			return true;
		},
		/**
		 * 取消sessionStorage
		 */
		readStorage:function(key){
			if(typeof window.sessionStorage == 'undefined'){ 	alert("请在微信客户端打开链接");return false;}
			return sessionStorage.getItem(key);;
		},
		clearStorage:function(){
			if(typeof window.sessionStorage == 'undefined'){ 	alert("请在微信客户端打开链接");return false;}
			return sessionStorage.clear();
		},
		/**
		 * 读取微信开发平台ID
		 */
		readOpenId:function(){
			return sessionStorage.get('openId');
		},
		/**
		 * 读取店铺ID
		 */
		readShopId:function(){
			return sessionStorage.get('shopId');
		}
	}
}();